package com.concurrency.synchronize;

import java.util.ArrayList;
import java.util.List;

/**
 * 多线程访问同一个list对象，对list对象加锁。
 * @author David
 *
 */
public class PositionListService {
	static List<Integer> list = new ArrayList<Integer>();
	private String name;
	
	public PositionListService(String name){
		this.name = name;
	}
	
	public void use(){
		synchronized(list){
			list.add(1);
			System.out.println(name+"进入，总人数："+list.size());
		}

	}

}
